{% extends 'web/layout/basic.html' %}
{% load static %}

{% block title %}
    LOGIN
{% endblock %}

{% block css %}
    <link rel="stylesheet" href="{% static 'web/css/account/register.css' %}">
{% endblock %}

{% block content %}
    <div class="account">
        <div class="title">用户登录</div>
        <form id="smsLoginForm" method="post" action="{% url 'login' %}" novalidate>
            {% csrf_token %}
            {% for field in login_form %}
                {% if field.name == 'code' %}
                    <div class="form-group">
                        <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                        <div class="clearfix">
                            <div class="col-md-7" style="padding-left: 0">
                                {{ field }}
                                <span class="error-msg">{{ field.errors.0 }}</span>
                            </div>
                            <div class="col-md-5">
                                <img src="{% url 'image_code' %}" alt="" title="点我更新验证码" id="imageCode">
                            </div>
                        </div>
                    </div>
                {% else %}
                    <div class="form-group">
                        <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                        {{ field }}
                        <span class="error-msg">{{ field.errors.0 }}</span>
                    </div>
                {% endif %}
            {% endfor %}
            <div>
                <div style="float: right;">
                    <a href="{% url 'login_sms' %}">短信验证码登录?</a>
                </div>
            </div>
            <input type="submit" class="btn btn-primary" id="btnSubmit" value="登 录">
        </form>
    </div>
{% endblock %}

{% block js %}
    <script>
        $(function () {
            $('#imageCode').click(function () {
                var oldSrc = $(this).attr('src');
                $(this).attr('src', oldSrc + '?');
            })
        })
    </script>
{% endblock %}
